/*Que : 5
 * Write a program to implement "ECHO Server " using socket.
 * 
 * This is server.
 */

import java.net.*;
import java.io.*;

/**
 *
 * @author savan
 */
public class P5_server {

    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(888);
        System.out.println("Exho server created at port no. 888");
        Socket s = ss.accept();        
        PrintStream ps = new PrintStream(s.getOutputStream());        
        BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
        while (true) {
            String str, str1;            
            while ((str = br.readLine()) != null) {
                System.out.println(str);
                ps.println(str);
            }
            ps.close();
            br.close();
            ss.close();
            s.close();
            System.exit(0);
        }
    }
}
